package io.webchat.minio;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class MinloUploadServiceImpl implements MinloUploadService {

    @Autowired
    private MinIOConfig minIOConfig ;



    // 上传 <img> ,返回服务器地址
    @Override
    public String uploadImg(String imgName, String imgPath){
        String  imagePath="";
        try {
            imagePath = minIOConfig.uploadImg(imgName, imgPath);
        }catch (Exception e){
            e.printStackTrace();
        }
        return imagePath;
    }

    @Override
    public String uploadImg(MultipartFile file, String bucketName){
        String  imagePath="";
        try {
            imagePath = minIOConfig.uploadImg(file, bucketName);
        }catch (Exception e){
            e.printStackTrace();
        }
        return imagePath;
    }
}
